package utils;

import com.alibaba.fastjson.JSONObject;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by adinlead on 17-7-13.
 */
public class Pagger {
    final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    public Pagger() {
    }

    /**
     *
     * @param page 页码
     * @param linage 行数
     * @param records 总记录数
     * @param rows 记录主体
     */
    public Pagger(int page, int linage, Long records, List rows) {
        this.page = page;
        this.linage = linage;
        this.records = records.intValue();
        this.rows = rows;
        total = (int) Math.ceil((double) records / (double) linage);
    }

    private int status = 200;
    //    页码
    public int page;
    //    行数
    public int linage;
    //    总页码
    public int total;
    //    记录总数
    public int records;
    //    记录主体
    public List rows;

    public JSONObject toJSON() {
        JSONObject json = new JSONObject();
        json.put("page", this.page);
        json.put("linage", this.linage);
        json.put("total", this.total);
        json.put("records", this.records);
        json.put("rows", this.rows);
        json.put("status", this.status);
        json.put("remind", "");
        return json;
    }


}
